const crypto = require('crypto');

// 用户名
const user = '小明';
// 盐  加盐
const secret = 'abcdefg';
const hash = crypto.createHmac('sha256', secret)
                   .update(user)
                   .digest('hex');
console.log(hash);